/*
 * camera_drv.c
 *
 * Created: 20.03.2013 21:22:39
 *  Author: Timmo
 */ 

#include <avr/io.h>
#include <util/delay.h>

#include "settings.h"
#include "camera_drv.h"
#include "ir_drv.h"
#include "timer_functions.h"

void shutter_toggle(){
	
    if(mt_settings.use_ir == 1){
        IR_Trigger(mt_settings.camera_type);
    }
    else{        
	    shutter_press();
	    _delay_ms(TOGGLE_TIME);
	    shutter_release();
    }    
}


void shutter_press(){
	if(mt_settings.focus_shutter){
		focus_press();
		if(mt_settings.prefocus_time > 0){
			waitms(mt_settings.prefocus_time);
		}
	
	}
	CAMERA_PORT.OUTSET = (1<<SHUTTER_PIN);
}

void shutter_release(){
	CAMERA_PORT.OUTCLR = (1<<SHUTTER_PIN);
	if(mt_settings.focus_shutter){
		focus_release();	
	}	
}

void camera_wakeup(){
	focus_press();
	_delay_ms(TOGGLE_TIME);
	focus_release();
	
}
